feat(FR-2555): add useCurrentUserProjectRoles hook with myRoles RBAC query#6651
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 9.02% | 1770/19627 |
| 🔴 | Branches | 8.14% | 1115/13694 |
| 🔴 | Functions | 5.36% | 286/5335 |
| 🔴 | Lines | 8.71% | 1660/19058 |
Test suite run success
859 tests passing in 39 suites.
Report generated by 🧪jest coverage report action from 9dc530a
There was a problem hiding this comment.
Pull request overview
Adds a new RBAC-focused hook in the React WebUI to derive the current user’s project-admin scope by querying myRoles via Relay, with a pure helper function and unit tests to validate the derivation logic.
Changes:
- Introduces
useCurrentUserProjectRoles(RelaymyRolesquery + legacybaiClientsignals) anduseEffectiveAdminRole. - Adds
deriveProjectAdminIds+ UUID normalization and role-name fallback logic. - Adds Jest tests covering the derivation rules (primary permission signal vs fallback, normalization, dedupe, edge cases).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| react/src/hooks/useCurrentUserProjectRoles.ts | Implements the myRoles Relay query, derives project-admin IDs, and exposes hooks for effective admin role selection. |
| react/src/hooks/tests/useCurrentUserProjectRoles.test.tsx | Unit tests for deriveProjectAdminIds covering primary/fallback behavior, normalization, deduplication, and malformed inputs. |
32b533a to
4181d2d
Compare
4181d2d to
e0a3057
Compare
e0a3057 to
5ac5f01
Compare
Merge activity
|
…query (#6651) Resolves #6641 (FR-2555) Part of FR-2209 Project Admin Management stack (PR-1). ## Summary - Add `useCurrentUserProjectRoles` hook that inspects the `myRoles` RBAC query and reports project admin scope - Expose `deriveProjectAdminIds` (pure function) and `useEffectiveAdminRole` derived hook - Use `@catch(to: RESULT)` so older cores without the `myRoles` field fall back to empty admin arrays instead of throwing ## Verification - `bash scripts/verify.sh` → `=== ALL PASS ===` - Unit tests: `react/src/hooks/__tests__/useCurrentUserProjectRoles.test.tsx`
5ac5f01 to
9dc530a
Compare
…tor (#6653) Resolves #6644 (FR-2552) Part of FR-2209 Project Admin Management stack (PR-1a). Stacks on #6651. ## Summary - `useWebUIMenuItems` now gates admin-category keys by `useEffectiveAdminRole()`; project admins see only Session/Serving/Data/Members - `WebUISider` uses 3-tier `hasAdminCategoryRole = useEffectiveAdminRole() !== 'none'` - `ProjectSelect` renders a "Project Admin" badge on admin-scoped projects for project-admin-only users ## Verification - `bash scripts/verify.sh` -> `=== ALL PASS ===`

Resolves #6641 (FR-2555)
Part of FR-2209 Project Admin Management stack (PR-1).
Summary
useCurrentUserProjectRoleshook that inspects themyRolesRBAC query and reports project admin scopederiveProjectAdminIds(pure function) anduseEffectiveAdminRolederived hook@catch(to: RESULT)so older cores without themyRolesfield fall back to empty admin arrays instead of throwingVerification
bash scripts/verify.sh→=== ALL PASS ===react/src/hooks/__tests__/useCurrentUserProjectRoles.test.tsx